﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MarvellousWorks.PracticalPattern.FactoryMethod.GenericFactory
{
    public class DelegateFactory
    {
    }

    public delegate int CalculatorHandler(params int[] args);

    public class Calculator
    {
        public int Add(params int[] args)
        {
            int result = 0;
            foreach (int arg in args)
            {
                result += arg;
            }
            return result;
        }

        public Func<int[], int> Add2 = args =>
        {
            return args.Sum();
        };
    }

    public class CalculatorHandlerFactory : IFactory<CalculatorHandler>
    {
        public CalculatorHandler Create()
        {
            return (new Calculator()).Add;
        }
    }


}
